﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;

namespace QaaSimulation.QSim.Ships
{
    class QEngineBox : QShipBox
    {
        public QEngineBox()
            : base()
        {
            m_Crew = -5;
            m_Energy = -20;
        }

        private GraphicsPath CreatePath()
        {
            GraphicsPath path = new GraphicsPath();
            path.AddLine(0, QModelBox.BOX_RELATION * 0.2f, QModelBox.BOX_RELATION, QModelBox.BOX_RELATION * 0.2f);
            path.AddLine(QModelBox.BOX_RELATION, QModelBox.BOX_RELATION * 0.2f, QModelBox.BOX_RELATION * 0.8f, QModelBox.BOX_RELATION * 0.6f);
            path.AddLine(QModelBox.BOX_RELATION * 0.8f, QModelBox.BOX_RELATION * 0.6f, QModelBox.BOX_RELATION * 0.2f, QModelBox.BOX_RELATION * 0.6f);
            path.CloseFigure();
            return path;
        }

        public override void Paint(System.Drawing.Graphics g)
        {
            GraphicsPath path = CreatePath();
            
            g.FillPath(Brushes.LightGray, path);
            g.DrawPath(Pens.Black, path);
            g.FillRectangle(Brushes.DarkOrange, new RectangleF(0, 0, QModelBox.BOX_RELATION, QModelBox.BOX_RELATION * 0.2f));
            g.DrawRectangle(Pens.Black, new Rectangle(0, 0, QModelBox.BOX_RELATION, (int)(QModelBox.BOX_RELATION * 0.2f)));
        }

        public override bool CanBePlaced(QShipBox[] neighborhood)
        {
            if (neighborhood[(int)QBoxSide.Bottom] != null)
                return false;

            return true;
        }
    }
}
